<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%@page import="com.hertz.appr.pojo.Admin"%>
<%@page import="com.hertz.appr.oauth.OAuth"%>
<%@page import="com.hertz.appr.oauth.RequestToken"%>
<%@page import="com.hertz.appr.util.Configuration"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String name = (String)request.getSession().getAttribute("name");
String password = (String)request.getSession().getAttribute("password");
if(name == null || name.equals("")){
	response.sendRedirect("../index.jsp");
}
if(name.equals(Admin.name) && password.equals(Admin.password)){
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>add_robot</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
    <%
    	String provider = "qq";
    	String callBack = "http://localhost:8080/app-r/gang/add_robot_callback.jsp";
    	OAuth oauth = new OAuth(provider);
    	RequestToken requestToken = oauth.getOauthRequestToken(callBack);
    	
    	session.setAttribute("resToken",requestToken);
     %>
     <a href='<%=Configuration.getAuthorizeUrl(provider) + "?oauth_callback=" +callBack + "&" + "oauth_token=" + requestToken.getToken() %>' + >add robot 4 qq</a><br>
     <%
    	OAuth oauthSina = new OAuth("sina");
    	String callBack4sina = "http://localhost:8080/app-r/gang/add_robot_callback4sina.jsp";
    	RequestToken requestTokenSina = oauthSina.getOauthRequestToken(callBack4sina);
    	
    	session.setAttribute("resToken",requestTokenSina);
     %>
     
     <a href='<%=Configuration.getAuthorizeUrl("sina") + "?oauth_callback=" +callBack4sina + "&" + "oauth_token=" + requestTokenSina.getToken() %>' + >add robot 4 sina</a><br>
     
  </body>
</html>
<%} else {
response.sendRedirect("../index.jsp");
}
%>
